<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <link rel="stylesheet" href=""> -->
    <style>
        #demo {
            width: 200px;
            height: 200px;
            background-color: #6ff;
            margin: 50px;
        }
    </style>
</head>

<body>
    <div>
        <button class="get">获取</button>
        <button class="set">设置</button>
    </div>

    <a href="https://www.baidu.com" target="_self">
        <img src="../images/bg_4.jpg" alt="">
    </a>
</body>
<script>
    var getBtn = document.getElementsByClassName("get")[0];
    var setBtn = document.getElementsByClassName("set")[0];

    var a = document.querySelector("a");
    var img = document.querySelector("img");

    // 元素节点的属性 _ 续
    // href     获取和设置元素的href属性(a href)
    // target   获取和设置元素的target属性
    // src      获取和设置元素的src属性 (img script input:image)

    getBtn.onclick = function () {
        console.log(a.href);
        console.log(a.target);
        console.log(img.src);
        console.log(img.alt);
    }

    setBtn.onclick = function () {
        a.href = "https://www.jd.com";
        a.target = "_blank";
        img.src = "../images/bg_5.jpeg";
        img.alt = "123123";
    }





</script>

</html>